import { Input, Button } from "antd";
import React, { useState } from "react";
import { unstable_batchedUpdates } from "react-dom";
const BatchUpdate: React.FC = () => {
  const [a, setA] = useState(1);
  const [b, setB] = useState({});
  const [c, setC] = useState(1);
  const handerClick = () => {
    Promise.resolve().then(() => {
      unstable_batchedUpdates(() => {
        setB({ ...b });
        setC(c + 1);
        setA(a + 1);
        console.log(a, b, c);
      });
    });
  };
  return (
    <div>
      <Input placeholder="Basic usage" style={{ width: "300px" }} />
      <Button type="default" onClick={handerClick}>
        确认
      </Button>{" "}
      <div>1</div>
    </div>
  );
};

export default BatchUpdate;
